import base64

import requests

def call_transfer_api(title:str, speech: bytes, from_user: str, to_user:str):
    url = "http://api.ai.rmd.com.cn/open/asr/offline"
    headers = {
        "Authorization": "Access=1"
    }
    myParams = {"itn": True, "fs": 8000, "wav": base64.b64encode(speech), 'title': title, 'format': 'alaw', 'fromUser':from_user, 'toUser':to_user}
    res = requests.post(url=url,headers=headers, json=myParams)

    print("response:", res.text)  # 返回请求结果
with open("/home/leo/Downloads/1eb9c186-6ef9-40a2-b2bf-7a9ecb3d7b03.wav", "rb") as file:
    data = file.read()
    file.close()
    call_transfer_api(title=f'1eb9c186-6ef9-40a2-b2bf-7a9ecb3d7b03', speech=data, from_user='from_user', to_user='to_user')
